﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameObjects.DrawableClasses;
using Virvar.Net;

namespace GameProcess.Actors
{
    class HealthActor : IPacketHandler
    {
        GameState gameState;

        public HealthActor(GameState gameState)
        {
            this.gameState = gameState;
        }

        public void ReceiveServer(Virvar.Net.ClientPacket msg)
        {
        }

        public void ReceiveClient(Virvar.Net.ServerPacket msg)
        {
            foreach (var playerHealth in msg.PlayersHealths)
            {
                // обновление состояния здоровья персонажа
                if (gameState.Players.ContainsKey(playerHealth.Key))
                    gameState.Players[playerHealth.Key].Health = playerHealth.Value;
            } 
            foreach (var playerMana in msg.PlayersMana)
            {
                // обновление состояния маны персонажа
                if (gameState.Players.ContainsKey(playerMana.Key))
                    gameState.Players[playerMana.Key].Mana = playerMana.Value;
            }
        }
    }
}
